package com.googlecode.pacswitch;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;

import com.googlecode.pacswitch.actions.BestProxy;
import com.googlecode.pacswitch.actions.Direct;
import com.googlecode.pacswitch.actions.Pac;
import com.googlecode.pacswitch.actions.Plain;
import com.googlecode.pacswitch.actions.PlainAdapter;
import com.googlecode.pacswitch.actions.Proxy;
import com.googlecode.pacswitch.actions.Redirect;
import com.googlecode.pacswitch.actions.Response;
import com.googlecode.pacswitch.actions.Proxies;
import com.googlecode.pacswitch.conditions.And;
import com.googlecode.pacswitch.conditions.LocalHost;
import com.googlecode.pacswitch.conditions.LocalNet;
import com.googlecode.pacswitch.conditions.Not;
import com.googlecode.pacswitch.conditions.Or;
import com.googlecode.pacswitch.conditions.RequestPort;

@XmlRegistry
public class ObjectFactory implements ConfigRegistry {
    public static final String NS = "http://code.google.com/p/pacswitch";
    public static final String CNS = "http://code.google.com/p/pacswitch/conditions";
    public static final String ANS = "http://code.google.com/p/pacswitch/actions";
    public static final String PNS = "http://code.google.com/p/pacswitch/properties";

    @XmlElementDecl(namespace = NS, name = "config")
    public JAXBElement<Config> createConfigElement(final Config value) {
        return new JAXBElement<Config>(new QName(NS, "config"), Config.class,
                value);
    }

    // _________________________ Conditions ____________________________________

    @XmlElementDecl(namespace = CNS, name = "and")
    public JAXBElement<And> createAndElement(final And value) {
        return new JAXBElement<And>(new QName(CNS, "and"), And.class, value);
    }

    @XmlElementDecl(namespace = CNS, name = "or")
    public JAXBElement<Or> createOrElement(final Or value) {
        return new JAXBElement<Or>(new QName(CNS, "or"), Or.class, value);
    }

    @XmlElementDecl(namespace = CNS, name = "not")
    public JAXBElement<Not> createNotElement(final Not value) {
        return new JAXBElement<Not>(new QName(CNS, "not"), Not.class, value);
    }

    @XmlElementDecl(namespace = CNS, name = "localnet")
    public JAXBElement<LocalNet> createLocalNetElement(final LocalNet value) {
        return new JAXBElement<LocalNet>(new QName(CNS, "localnet"),
                LocalNet.class, value);
    }

    @XmlElementDecl(namespace = CNS, name = "localhost")
    public JAXBElement<LocalHost> createLocalHostElement(final LocalHost value) {
        return new JAXBElement<LocalHost>(new QName(CNS, "localhost"),
                LocalHost.class, value);
    }

    @XmlElementDecl(namespace = CNS, name = "requestport")
    public JAXBElement<RequestPort> createRequestPortElement(
            final RequestPort value) {
        return new JAXBElement<RequestPort>(new QName(CNS, "requestport"),
                RequestPort.class, value);
    }

    // __________________________ Actions ______________________________________

    @XmlElementDecl(namespace = ANS, name = "proxy")
    public JAXBElement<Proxy> createProxyElement(final Proxy value) {
        return new JAXBElement<Proxy>(new QName(ANS, "proxy"), Proxy.class,
                value);
    }

    @XmlElementDecl(namespace = ANS, name = "proxies")
    public JAXBElement<Proxies> createProxiesElement(final Proxies value) {
        return new JAXBElement<Proxies>(new QName(ANS, "proxies"),
                Proxies.class, value);
    }

    @XmlElementDecl(namespace = ANS, name = "bestproxy")
    public JAXBElement<BestProxy> createBestProxyElement(final BestProxy value) {
        return new JAXBElement<BestProxy>(new QName(ANS, "bestproxy"),
                BestProxy.class, value);
    }

    @XmlElementDecl(namespace = ANS, name = "direct")
    public JAXBElement<Direct> createDirectElement(final Direct value) {
        return new JAXBElement<Direct>(new QName(ANS, "direct"), Direct.class,
                value);
    }

    @XmlElementDecl(namespace = ANS, name = "redirect")
    public JAXBElement<Redirect> createRedirectElement(final Redirect value) {
        return new JAXBElement<Redirect>(new QName(ANS, "redirect"),
                Redirect.class, value);
    }

    @XmlElementDecl(namespace = ANS, name = "pac")
    public JAXBElement<Pac> createPacElement(final Pac value) {
        return new JAXBElement<Pac>(new QName(ANS, "pac"), Pac.class, value);
    }

    @XmlElementDecl(namespace = ANS, name = "response")
    public JAXBElement<Response> createResponseElement(final Response value) {
        return new JAXBElement<Response>(new QName(ANS, "response"),
                Response.class, value);
    }

    @XmlElementDecl(namespace = ANS, name = "plain")
    @XmlJavaTypeAdapter(PlainAdapter.class)
    public JAXBElement<Plain> createPlainElement(final Plain value) {
        return new JAXBElement<Plain>(new QName(ANS, "plain"), Plain.class,
                value);
    }

    // ________________________ Properties _____________________________________

    @XmlElementDecl(namespace = PNS, name = "proxy")
    public JAXBElement<Proxy> createProxyPropElement(final Proxy value) {
        return new JAXBElement<Proxy>(new QName(PNS, "proxy"), Proxy.class,
                value);
    }

    @XmlElementDecl(namespace = PNS, name = "proxies")
    public JAXBElement<Proxies> createProxiesPropElement(final Proxies value) {
        return new JAXBElement<Proxies>(new QName(PNS, "proxies"),
                Proxies.class, value);
    }

    @XmlElementDecl(namespace = PNS, name = "bestproxy")
    public JAXBElement<BestProxy> createBestProxyPropElement(
            final BestProxy value) {
        return new JAXBElement<BestProxy>(new QName(PNS, "bestproxy"),
                BestProxy.class, value);
    }
}
